// 用户相关类型
export interface User {
  id: number;
  username: string;
  email: string;
  nickname?: string;
  avatar?: string;
  createTime: string;
  updateTime: string;
  status?: number; // 用户状态：0-禁用，1-正常
  enabled?: boolean; // 是否启用
  emailVerified?: boolean; // 邮箱是否验证
  lastLoginTime?: string; // 最后登录时间
  isActive?: boolean; // 兼容旧版本
  roles: string[]; // 角色名称数组，如: ["USER", "ADMIN"]
  profile?: UserProfile;
  stats?: UserStats; // 用户统计信息
}

// 用户统计信息
export interface UserStats {
  postCount?: number;
  commentCount?: number;
  followingCount?: number;
  followerCount?: number;
  likeCount?: number;
  whisperCount?: number;
}

export interface UserProfile {
  id: number;
  userId: number;
  bio?: string;
  avatar?: string;
  gender?: string;
  phone?: string;
  location?: string;
  website?: string;
  birthday?: string;
  education?: string;
  profession?: string;
  privacySettings?: string;
  createTime: string;
  updateTime: string;
}

export interface Role {
  id: number;
  name: string;
  description?: string;
  permissions: string[];
}

// 帖子相关类型
export interface Post {
  id: number;
  userId: number;
  categoryId: number;
  title: string;
  content: string;
  excerpt?: string;
  tags?: string[];
  viewCount: number;
  likeCount: number;
  commentCount: number;
  isTop: boolean;
  status: string;
  createTime: string;
  updateTime: string;
  author: User;
  category: Category;
  comments?: Comment[];
  images?: string[];
}

export interface Category {
  id: number;
  name: string;
  description?: string;
  icon?: string;
  color?: string;
  sort: number;
  isActive: boolean;
  createTime: string;
  updateTime: string;
  postCount: number;
}

export interface Comment {
  id: number;
  postId: number;
  userId: number;
  parentId?: number;
  content: string;
  likeCount: number;
  createTime: string;
  updateTime: string;
  author: User;
  children?: Comment[];
}

// 悄悄话类型
export interface Whisper {
  id: number;
  targetType?: number; // 1: 用户名, 2: 暗号
  targetValue?: string; // 目标值
  content: string;
  isAnonymous: boolean;
  senderNickname?: string; // 发送者昵称
  authorName?: string;
  authorEmail?: string;
  createTime: string;
  updateTime: string;
  isPublic: boolean;
  replies?: WhisperReply[];
}

export interface WhisperReply {
  id: number;
  whisperId: number;
  content: string;
  createTime: string;
  updateTime: string;
}

// API响应类型
export interface ApiResponse<T = unknown> {
  code: number;
  message: string;
  data: T;
  timestamp: string;
}

export interface PageResult<T = unknown> {
  items: T[];
  total: number;
  totalPages: number;
  size: number;
  page: number;
  hasPrevious: boolean;
  hasNext: boolean;
  isFirst: boolean;
  isLast: boolean;
}

// 登录相关类型
export interface LoginRequest {
  usernameOrEmail: string;
  password: string;
  rememberMe?: boolean;
}

export interface RegisterRequest {
  username: string;
  email: string;
  password: string;
  confirmPassword: string;
  nickname?: string;
  agreeToTerms?: boolean;
}

export interface AuthResponse {
  accessToken: string;
  refreshToken: string;
  tokenType: string;
  expiresIn: number;
  userInfo: {
    id: number;
    username: string;
    email: string;
    nickname?: string;
    avatar?: string;
    roles: string[];
    emailVerified: boolean;
    lastLoginTime: string;
  };
}

// 分页参数
export interface PageParams {
  page?: number;
  size?: number;
  sort?: string;
  direction?: "ASC" | "DESC";
}

// 搜索参数
export interface SearchParams extends PageParams {
  keyword?: string;
  category?: number;
  tags?: string[];
  startDate?: string;
  endDate?: string;
}
